package com.lzy.cloud.base.controller;

import com.lzy.cloud.base.dto.BankTypeDto;
import com.lzy.cloud.base.request.BankTypeRequest;
import com.lzy.cloud.base.request.ShopBankRequest;
import com.lzy.cloud.base.response.BankTypeResponse;
import com.lzy.cloud.base.service.BankTypeService;
import com.lzy.framework.core.ensure.Ensure;
import com.lzy.framework.core.output.Result;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 银行卡识别
 *
 * @author lc
 * @version 2018/8/16
 */
@RestController
@RequestMapping("/bank/type")
public class BankTypeController {

    @Autowired
    private BankTypeService bankTypeService;

    /**
     * 根据卡号前6位得到银行卡信息
     * @param first
     * @return
     */
    @RequestMapping(value = "/find/{first}",method = RequestMethod.GET)
    public Result find(@PathVariable("first") Integer first) {
        Ensure.that(first.toString().length()).isEqual(6,"00030005");
        BankTypeDto dto = bankTypeService.findByFirst(first);
        Ensure.that(dto).isNotNull("00030006");
        return new Result(DozerUtils.map(dto,BankTypeResponse.class));
    }

}
